<template>
  <div style="height: 100%">
    <el-container>
      <!--      左侧菜单 SideBar组件-->
      <el-aside :width="sideBarWidth" class="aside">
        <side-bar/>
      </el-aside>
      <el-container>
        <!--      页面顶部 Header组件-->
        <el-header class="header">
          <div class="left">
            <div class="operate" ref="operate">
              <i class="iconfont icon-fold"/>
              <nav-bar/>
            </div>
            <!--         历史记录 ReuseTab组件-->
            <el-collapse-transition><reuse-tab ref="reuse"/></el-collapse-transition>
          </div>
        </el-header>
        <el-main class="main">
          <!--          右侧菜单 MenuTab组件-->
          <div class="menu-tab"></div>
          <!--         舞台 AppMain组件-->
          <app-main ref="appMain"></app-main>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import SideBar from '@/components/layout/side-bar'
import AppMain from '@/components/layout/app-main'
import NavBar from '@/components/layout/nav-bar'
import ReuseTab from '@/components/layout/reuse-tab'
import { SET_USER_MENUS } from '@/store/mutations-types'
import { mapMutations } from 'vuex'
const navBarHeight = 66 // header高度
const reuseTabHeight = 70 // 历史记录栏高度
const marginHeight = 20 // 历史记录栏与舞台的间距
const sideBarWidth = '210px'
// eslint-disable-next-line no-unused-vars
const totalHeight = navBarHeight + reuseTabHeight + marginHeight
export default {
  name: 'home',
  components: { ReuseTab, NavBar, AppMain, SideBar },
  inject:['eventBus'], //provide和inject是成对出现的 provide/inject可以轻松实现跨级访问父组件的数据
  data () {
    return {
      show3: false,
      isCollapse: false, // 左侧菜单栏是否折叠
      sideBarWidth, // 左侧菜单栏展开的宽度
      clientWidth: 0, // 页面宽度
      clientHeight: 0, // 页面高度
      foldState: false, // 控制左侧菜单栏按键
      isPhone: false,
    }
  },
  mounted () {
    this.eventBus.$on('noReuse', () => {
      this.$refs.operate.style.height = '86px'
    })
    this.eventBus.$on('hasReuse', () => {
      this.$refs.operate.style.height = '45px'
    })
  },
  methods: {},
  beforeDestroy () {
    this.eventBus.$off('noReuse')
    this.eventBus.$off('hasReuse')
  }
}
</script>

<style lang="scss" scoped>
.aside{
  background-color: rgb(25, 42, 94);
  overflow-x: hidden;

  &::-webkit-scrollbar {
    width: 0px;
    height: 0px;
  }
}
.header {
  padding: 0;
  background: $header-background;
  height: $header-height !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0px 2px 6px 0px rgba(190, 204, 216, 0.4);
  border-bottom: 1px solid rgba(190, 204, 216, 0.4);

  .left {
    height: 100%;
    width: 100%;

    .operate {
      display: flex;
      align-items: center;
      background: $header-background;
      padding-left: 20px;
      height: 45px;

      .iconfont {
        font-size: 16px;
        font-weight: 500;
        color: $right-side-font-color;
        cursor: pointer;
        transform: rotate(0deg);
        transition: all 0.3s linear;
        margin-right: 10px;

        &:hover {
          color: #3963bc;
        }
      }

      .rotate {
        transform: rotate(180deg);
        transition: all 0.3s linear;
      }
    }
  }

  .right-info {
    display: flex;
    align-items: center;
  }
}
.el-main {
  overflow-y: auto;
  position: relative;
  padding: 0;
}

.backTop {
  position: fixed;
  display: inline-block;
  text-align: center;
  cursor: pointer;
  right: 50px;
  bottom: 50px;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 50%;
  z-index: 99;
  background: #fff;

  .iconfont {
    font-size: 36px;
  }
}

.sidenav-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  z-index: 10;
  display: none;
  cursor: pointer;

  &.show {
    display: block;
  }
}
</style>
